<!doctype html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="Author" content="">
    <meta name="Keywords" content="">
    <meta name="Description" content="">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta content="telephone=no" name="format-detection" /> 
    
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
    <title>注册</title>
    <style type="text/css">
    html, body, div,section,article,canvas,header,footer,figure,figcaption,nav span, applet, object, iframe, h1, h2, h3, h4, h5, h6, p, dd, dl, dt, li, ol, ul,input,select,button,textarea,table,tr,td{ padding:0; margin:0; border:none;outline: none;}
	input,button,select,textarea,a,img{outline:none; text-decoration:none;color:#333;-webkit-tap-highlight-color:rgba(255,0,0,0);border:none;}
	section,article,header,footer,figure,figcaption,nav,canvas{display:block;}
	::-moz-focus-inner{border:0px;}
	body {font-size:10px; font-family: -apple-system-font,Helvetica Neue,sans-serif,"Microsoft YaHei","Arial", "SimSun";}
	html,body{width:100%;height:100%;overflow:hidden;background:#f2f2f2;-moz-user-select: none; -webkit-user-select: none; -ms-user-select: none; -khtml-user-select: none; user-select: none; }
	ul, ul li, ol li, li {  list-style:none;}
	table { border-collapse: collapse;border-spacing:0;}
	input, textarea {border: 0;vertical-align: middle;}
	.clearfix:after {visibility: hidden;display: block;font-size: 0;content: ".";clear: both;height: 0;}
	* html .clearfix {zoom: 1;}
	*:first-child + html .clearfix {zoom: 1;}
	
	.fl {   float:left;}
	.fr {   float:right;}
	.none{  display:none;}
	.elip{white-space:nowrap; overflow:hidden; text-overflow:ellipsis;}
	*{box-sizing: border-box;-webkit-box-sizing:border-box;}

	.wjmm_head{height:200px;text-align:center}
	.wjmmimg{width:120px;height:120px;background:rgba(255,255,255,.8);border-radius:50px;padding:5px;margin:0 auto;border-radius:300px;margin-top:30px}
	.wjmmimg img{width:100%;height:100%;display:block;overflow:hidden;background-size:100%;border-radius:300px}
	.wjmm_wqyzm{border:1px solid #ebebeb;border-radius:4px;background:#f9f9f9;padding:3px 10px;text-align:center;margin-right:10px;}
	.registerbox{position:absolute;width:100%;max-width:720px;top:0;left:0;background-color:#f7f7f7;overflow-x:hidden;overflow-y:auto;color:#333;text-align:center}
	.libox{background-color:#fff;width:100%;padding:3%;display:block;margin-bottom:10px;overflow:hidden}
	.libox_li{overflow:hidden;display:block;text-align:left;line-height:30px;padding:10px;font-size:14px}
	.li_left{width:30%;margin-top:3px}
	.li_left2{width:61%}
	.li_right{width:70%}
	.form-control{display:block;width:100%;padding:8px 0;font-size:14px;line-height:1.428571429;color:#555;border:0}
	.borderline_b{border-bottom:1px solid #ebebeb}
	.pull_left{float:left}
	.pull_right{float:right}
	.savesite_btn{position:relative;display:block;margin-left:auto;margin-right:auto;padding-left:14px;padding-right:14px;box-sizing:border-box;font-size:18px;text-align:center;text-decoration:none;color:#FFF;line-height:2.55555556;border-radius:5px;-webkit-tap-highlight-color:transparent;overflow:hidden;background-color:#E64340;margin:15px}
	.registerbox input:-webkit-autofill {
		-webkit-box-shadow: 0 0 0px 1000px white inset;
		border: 1px solid #CCC!important;
	}
    </style>
    
</head>
<body>
	<div class="registerbox">
	    <div class="libox mb10">
	        <div class="libox_li borderline_b"><span class="pull_left li_left">手机号：</span> <span class="pull_left li_right"><input id="regusername" type="tel" pattern="[0-9]*" placeholder="请输入手机号" class="form-control" autocomplete="new-regusername"></span></div>
	        <div class="libox_li borderline_b"><span class="pull_left li_left">验证码:</span> <span class="pull_left li_right" style="width: 100px;"><input type="number" pattern="[0-9]*" id="varify" placeholder="请输入验证码" class="form-control" autocomplete="new-varify"></span> <span class="pull_right wjmm_wqyzm">获取验证码</span></div>
	        <div class="libox_li borderline_b"><span class="pull_left li_left">密码:</span> <span class="pull_left li_right"><input type="password" placeholder="请输入密码(长度至少6位)" id="regpassword" class="form-control"  autocomplete="new-regpassword"></span></div>
	        <div class="libox_li borderline_b"><span class="pull_left li_left">确认密码:</span> <span class="pull_left li_right"><input type="password" placeholder="请再次输入密码" class="form-control" id="passwordfirm" autocomplete="new-passwordfirm"></span></div>
	    </div>
	    <p class="err_msg" style="text-align:center;line-height:20px;height:20px;color:#E64340;font-size:14px;margin-top:-20px;"></p>
	    <div class="savesite_btn">注册</div>
	</div>
	<script type="text/javascript" src="src/js/jquery-1.10.1.min.js?__version=9.4"></script>
  <script type="text/javascript" src="src/js/init.js?__version=9.4"></script>
  <script src="https://res.wx.qq.com/open/js/jweixin-1.0.0.js"></script>
    <script src="/src/js/share.js?__version=9.4"></script>
	<script type="text/javascript">
	  var countdown=120;
      var timer="";
      $(document).on("click",".wjmm_wqyzm",function(){
              clearInterval(timer);
              var phoneStr = $("#regusername").val();
              var _this=$(this);
              //检测是否手机号
              //var validateCode = $("#verify").val();
                  if((phoneStr !=null) && (phoneStr !='')&& (phoneStr.length==11)){
                          //正则校验
                          var reg = /^(0|86|17951)?(13[0-9]|15[012356789]|17[678]|18[0-9]|14[57])[0-9]{8}$/;
                          var arr = phoneStr.match(reg);
                          if(arr !=null && arr.length !=0) {
                              var phone = parseInt(phoneStr);
                              var timer=setInterval(function(){
                                  countdown--;
                                  _this.text(countdown+"s").attr("disabled",true).removeClass("false");
                                  if(countdown==0){
                                      countdown=120;
                                      _this.text("获取").attr("disabled",false).addClass("false");
                                      clearInterval(timer);
                                  }
                              },1000)
                              $.ajax({
                                  url:api_url+'/OpenAPI/V1/SMS/sendSMS',
                                  type: 'get',
                                  dataType: 'JSON', 
                                  data:{phone:phone},
                                  success: function(data) {
                                          if(data.code == "000000"){
                                              //location.reload();
                                              console.log(data);
                                          }else{
                                              $(".err_msg").html(data.info);
                                              console.log(data);
                                          }
                                    }
                                })
                          }else{
                              $(".err_msg").html("请填写正确的手机号");
                          }
                      }else{
                          $(".err_msg").html("请填写正确的手机号");
                      }
                  
      });
      
      $(document).on("click",".savesite_btn",function(){
              regfn();
      });
      function regfn(){
          var passf=$("#passwordfirm").val();
          var password=$("#regpassword").val();
          var userName = $("#regusername").val();
          var verify = $("#varify").val(); 
          //var validateCode = $("#verify").val();
          if(userName==""){
            $(".err_msg").html("手机号不能为空");
            return;
          }
          if(regpassword==""){
            $(".err_msg").html("密码不能为空");
            return;
          }
          if(password == passf){
                $.ajax({
                  url:api_url+'/OpenAPI/V1/user/registerByPhone',
                  type: 'get',
                  dataType: 'JSON', 
                  data:{username:userName,password:password,captcha:verify,recommend:cookieGet('recommend')},
                  success: function(data) {
                        if(data.code == 0){
                          console.log(data.msg);
                            location.replace(document.referrer);
                            $(".err_msg").html(data.msg);
                        }else{
                          console.log(data.msg);
                          $(".err_msg").html(data.msg);
                        }
                    }
                });
          }else{
            console.log("密码不相同");
            $(" .err_msg").html('密码不相同');
          }
      }

	</script>
</body>
</html>